/*
 * GoHomeAndSleepTilRested.java
 *
 * Created on March 27, 2007, 11:18 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package ai9hells.pgaibe.chapter2.westworld1;

/**
 *
 * @author andre.bandarra
 */
public class GoHomeAndSleepTilRested extends State {
    public static final State INSTANCE = new GoHomeAndSleepTilRested();
    /** Creates a new instance of GoHomeAndSleepTilRested */
    private GoHomeAndSleepTilRested() {
    }

    public void enter(BaseGameEntity entity) {
        Miner m = (Miner)entity;
        if (m.getLocation() != Locations.SHACK){
            System.out.println(EntityNames.getNameOfEntity(m.getId())+": Walkin' home");
            m.setLocation(Locations.SHACK);
        }
    }

    public void execute(BaseGameEntity entity) {
        Miner m = (Miner)entity;       
        if (!m.isFatigued()){
            System.out.println(EntityNames.getNameOfEntity(m.getId())+": What a God darn fantastic nap! Time to find more gold");
            m.changeState(EnterMineAndDigForNugget.INSTANCE);
        } else {
            System.out.println(EntityNames.getNameOfEntity(m.getId())+": ZZZZZZZZZ!");
            m.decreaseFatigue();
        }
    }

    public void exit(BaseGameEntity entity) {
        Miner m = (Miner)entity;        
        System.out.println(EntityNames.getNameOfEntity(m.getId())+": Leaving the house");
    }
    
}
